/*
 * Copyright (c) 2023 iQi.Co.Ltd. All rights reserved.
 */
 
using IQIGame.Onigao.Framework;
using System.Collections.Generic;
using System.Linq;
using System;
using NetProtocol.Enum;

namespace NetProtocol.POD {

	/// <summary>
	/// 
	/// module : battleLogic
	/// </summary>
	public class BattleUnitViewPOD : IPOD 
    {
        public readonly static Func<BattleUnitViewPOD> FACTORY = () => new BattleUnitViewPOD();
		public static Func<BattleUnitViewPOD> DynamicFactory = FACTORY;
        
		/*-- members --*/
		/// <summary>
        /// 
        /// </summary>
		public int guid;
		/// <summary>
        /// 
        /// </summary>
		public long pid;
		/// <summary>
        /// 
        /// </summary>
		public int configID;
		/// <summary>
        /// 
        /// </summary>
		public int skinID;
		/// <summary>
        /// 
        /// </summary>
		public int unitType;
		/// <summary>
        /// 
        /// </summary>
		public int level;
		/// <summary>
        /// 
        /// </summary>
        private List<int> m_attr;
		/// <summary>
        /// 
        /// </summary>
        private List<int> m_skill;
		/// <summary>
        /// 
        /// </summary>
		public int radius;
		/// <summary>
        /// 
        /// </summary>
		public Vector2POD pos;
		/// <summary>
        /// 
        /// </summary>
		public Vector2POD forward;
		/// <summary>
        /// 
        /// </summary>
		public int weaknessPoint;
		/// <summary>
        /// 
        /// </summary>
		public int weaknessType;
		/// <summary>
        /// 
        /// </summary>
        private List<int> m_flankAngle;
		/// <summary>
        /// 
        /// </summary>
        private List<int> m_backAngle;
		/// <summary>
        /// 
        /// </summary>
		public int pet;
		
		
        public List<int> attr
        {
            get
            {
                if(m_attr == null)
                {
                    m_attr = new();
                }
                return m_attr;
            }
            private set => m_attr = value;
        }
        public List<int> unsafe_attr
        {
        	get => m_attr;
        	set => m_attr = value;
        }
        public List<int> skill
        {
            get
            {
                if(m_skill == null)
                {
                    m_skill = new();
                }
                return m_skill;
            }
            private set => m_skill = value;
        }
        public List<int> unsafe_skill
        {
        	get => m_skill;
        	set => m_skill = value;
        }
        public List<int> flankAngle
        {
            get
            {
                if(m_flankAngle == null)
                {
                    m_flankAngle = new();
                }
                return m_flankAngle;
            }
            private set => m_flankAngle = value;
        }
        public List<int> unsafe_flankAngle
        {
        	get => m_flankAngle;
        	set => m_flankAngle = value;
        }
        public List<int> backAngle
        {
            get
            {
                if(m_backAngle == null)
                {
                    m_backAngle = new();
                }
                return m_backAngle;
            }
            private set => m_backAngle = value;
        }
        public List<int> unsafe_backAngle
        {
        	get => m_backAngle;
        	set => m_backAngle = value;
        }
		
		/*-- constructors --*/
		public BattleUnitViewPOD() {}
		public BattleUnitViewPOD(int guid, long pid, int configID, int skinID, int unitType, int level, List<int> attr, List<int> skill, int radius, Vector2POD pos, Vector2POD forward, int weaknessPoint, int weaknessType, List<int> flankAngle, List<int> backAngle, int pet) {
			this.guid = guid;
			this.pid = pid;
			this.configID = configID;
			this.skinID = skinID;
			this.unitType = unitType;
			this.level = level;
			this.m_attr = attr;
			this.m_skill = skill;
			this.radius = radius;
			this.pos = pos;
			this.forward = forward;
			this.weaknessPoint = weaknessPoint;
			this.weaknessType = weaknessType;
			this.m_flankAngle = flankAngle;
			this.m_backAngle = backAngle;
			this.pet = pet;
		}
	      public void Serial(SOutputStream _out) {
            _out.Write_int(guid);
            _out.Write_long(pid);
            _out.Write_int(configID);
            _out.Write_int(skinID);
            _out.Write_int(unitType);
            _out.Write_int(level);
            _out.Write_list_int(m_attr); 
            _out.Write_list_int(m_skill); 
            _out.Write_int(radius);
            _out.Write_pod(pos);
            _out.Write_pod(forward);
            _out.Write_int(weaknessPoint);
            _out.Write_int(weaknessType);
            _out.Write_list_int(m_flankAngle); 
            _out.Write_list_int(m_backAngle); 
            _out.Write_int(pet);
        }
        
        public void UnSerial(SInputStream _in) {
            if(!_in.HasRemaining()) return;
            guid = _in.Read_int();
            if(!_in.HasRemaining()) return;
            pid = _in.Read_long();
            if(!_in.HasRemaining()) return;
            configID = _in.Read_int();
            if(!_in.HasRemaining()) return;
            skinID = _in.Read_int();
            if(!_in.HasRemaining()) return;
            unitType = _in.Read_int();
            if(!_in.HasRemaining()) return;
            level = _in.Read_int();
            if(!_in.HasRemaining()) return;
            m_attr = _in.Read_list_int();
            if(!_in.HasRemaining()) return;
            m_skill = _in.Read_list_int();
            if(!_in.HasRemaining()) return;
            radius = _in.Read_int();
            if(!_in.HasRemaining()) return;
            pos = _in.Read_pod<Vector2POD>(Vector2POD.DynamicFactory);
            if(!_in.HasRemaining()) return;
            forward = _in.Read_pod<Vector2POD>(Vector2POD.DynamicFactory);
            if(!_in.HasRemaining()) return;
            weaknessPoint = _in.Read_int();
            if(!_in.HasRemaining()) return;
            weaknessType = _in.Read_int();
            if(!_in.HasRemaining()) return;
            m_flankAngle = _in.Read_list_int();
            if(!_in.HasRemaining()) return;
            m_backAngle = _in.Read_list_int();
            if(!_in.HasRemaining()) return;
            pet = _in.Read_int();
        }
		
		public BattleUnitViewPOD Clone() {
            BattleUnitViewPOD o = DynamicFactory();
            o.guid = guid;
            o.pid = pid;
            o.configID = configID;
            o.skinID = skinID;
            o.unitType = unitType;
            o.level = level;
            if (m_attr != null) {
                o.m_attr = new (m_attr);
            }
            if (m_skill != null) {
                o.m_skill = new (m_skill);
            }
            o.radius = radius;
            if (pos != null) {
                o.pos = pos.Clone();
            }
            if (forward != null) {
                o.forward = forward.Clone();
            }
            o.weaknessPoint = weaknessPoint;
            o.weaknessType = weaknessType;
            if (m_flankAngle != null) {
                o.m_flankAngle = new (m_flankAngle);
            }
            if (m_backAngle != null) {
                o.m_backAngle = new (m_backAngle);
            }
            o.pet = pet;
            return o;
        }
        
        public void Clear() {
            guid = default;
            pid = default;
            configID = default;
            skinID = default;
            unitType = default;
            level = default;
            m_attr = default;
            m_skill = default;
            radius = default;
            pos = default;
            forward = default;
            weaknessPoint = default;
            weaknessType = default;
            m_flankAngle = default;
            m_backAngle = default;
            pet = default;
        }
		
        public override string ToString() {
			string str = "";
			str += "BattleUnitViewPOD [";
			str += "guid=";
			str += guid;
			str += ", pid=";
			str += pid;
			str += ", configID=";
			str += configID;
			str += ", skinID=";
			str += skinID;
			str += ", unitType=";
			str += unitType;
			str += ", level=";
			str += level;
			str += ", attr=";
			str += m_attr.ToString<int>();
			str += ", skill=";
			str += m_skill.ToString<int>();
			str += ", radius=";
			str += radius;
			str += ", pos=";
			str += pos;
			str += ", forward=";
			str += forward;
			str += ", weaknessPoint=";
			str += weaknessPoint;
			str += ", weaknessType=";
			str += weaknessType;
			str += ", flankAngle=";
			str += m_flankAngle.ToString<int>();
			str += ", backAngle=";
			str += m_backAngle.ToString<int>();
			str += ", pet=";
			str += pet;
			str += "]";
			return str;
		}
		
	}
}